package pulsar_topic_subscribe

import (
	"github.com/apache/pulsar-client-go/pulsar"
	"go_19/initialize"
)

type TopicSubscribeStruct struct {
	Topic initialize.TopicConsumer `json:"topic"`
}

func TopicSubscribe(subscribeStruct TopicSubscribeStruct) {
	client := initialize.PulsarClient(subscribeStruct.Topic.ClientOption)
	client.Subscribe(pulsar.ConsumerOptions{
		Topic:            subscribeStruct.Topic.Topic,
		SubscriptionName: subscribeStruct.Topic.SubscriptionName,
		Type:             0,
	})
	defer func() {
		client.Close()
	}()
}
